/*
 * @Author: master
 * @Date: 2021-12-01 13:58:24
 * @LastEditTime: 2022-04-04 09:55:04
 * @Description: 网络服务
 */
import http from '@/common/http/http.js';
const httpServer = (url, options) => {
  if (!options.headers) {
    options.headers = {};
  }
  // 如果存在需要取消的方式，则返回{promise，cancel()}
  if (options.isCancel) {
    return http(url, options);
  }
  return new Promise((resolve, reject) => {
    http(url, options)
      .then(res => {
        if (res.code === '200' || options.responseType === 'blob') {
          resolve(res);
        } else {
          reject(res);
        }
      })
      .catch(res => {
        reject(res);
      });
  });
};

export default httpServer;
